package net.sourceforge.peertwitter.scamp.messaging;

import rice.p2p.commonapi.Id;
import rice.p2p.commonapi.NodeHandle;

public class HeartbeatMessage extends ScampMessage {


//	private static final int TYPE = 5;
	private boolean shouldAnswear;
	
	private static final long serialVersionUID = -714407835065623367L;
	
	public HeartbeatMessage(NodeHandle sender, long timestamp, Id group) {
		super(group, sender, timestamp);
		shouldAnswear = true;
	}
	

//	@Override
//	public void serialize(OutputBuffer buf) throws IOException {
//		buf.writeBoolean(shouldAnswear);
//	}
	

	public void answered() {
		shouldAnswear = false;
	}
	
	public boolean shouldAnswear() {
		return shouldAnswear;
	}


	@Override
	public int hashCode() {
		final int prime = 31;
		int result = super.hashCode();
		result = prime * result;
		return result;
	}


	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (!super.equals(obj))
			return false;
		if (getClass() != obj.getClass())
			return false;
		return true;
	}


	@Override
	public String toString() {
		return "HeartbeatMessage [shouldAnswear=" + shouldAnswear
				+ ", getSender()=" + getSender() + ", getGroup()=" + getGroup()
				+ "]";
	}

//	@Override
//	public short getType() {
//		return TYPE;
//	}

}
